/*
 * Logger.h
 *
 *  Created on: Oct 25, 2012
 *      Author: johnny
 */

#ifndef LOGGER_H_
#define LOGGER_H_

#include <iostream>
#include <list>
#include <ctime>

#include "patterns/Observer.h"
#include "interfaces.h"

namespace core {

struct LogEntry {
    time_t timestamp;
    std::wstring message;
    std::wstring sender;
    ErrorType type;
};

typedef boost::shared_ptr<LogEntry> EntryPtr;
typedef std::list<EntryPtr>         LogList;

class Logger: public interfaces::LoggerIfc, public patterns::Observable {
	Logger();
    Logger(Logger const&) {}
    void operator=(Logger const&) {}

    LogList log;
public:
	virtual ~Logger();

    void add(ErrorType errType, std::string message, std::wstring sender = L"");
    void add(ErrorType errType, std::wstring message, std::wstring sender = L"");
    void addObserver(patterns::Observer *obs);

    const LogList &getFullLog();
	static Logger& getInstance();
};

} /* namespace core */
#endif /* LOGGER_H_ */
